function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); // 构造一个含有目标参数的正则表达式对象
    var r = window.location.search.substr(1).match(reg);  // 匹配目标参数
    if (r != null) return unescape(r[2]);
    return null; // 返回参数值
}

var code = getUrlParam('code');

layui.config({
    base: '/plugins/layui/extend/modules/',
    version: false
}).use(['table', 'jquery', 'ht_cookie', 'ht_config'], function () {
    var $ = layui.jquery;
    var config = layui.ht_config;
    $.ajax({
        type: "GET",
        url: config.basePath+"/sendinfo/createSendSalaryData?code=" + code,
        // url: "http://localhost:31506"+"/sendinfo/createSendSalaryData?code=" + code,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        async: false,
        success: function (result) {
            console.log("======:",result);
            if (result.returnCode == 0) {
                var dataAll = result.data;
                var sendType = dataAll.sendType;
                var contactName = dataAll.contactName;
                var emailType = dataAll.emailType;
                var otherInfo = dataAll.otherInfo;
                var data = dataAll.salaryData;
                var time = dataAll.timeStr;
                var checkTime = dataAll.checkTime;
                var salaryState = dataAll.salaryState;
                var $ulTemp;
                var $liTemp;
                // 1 志成 2 天大 3 联盛 4 富成 5 鸿特  6 志勤 7 车全
                var htLogo = $("#htLogo").html();
                var zcLogo = $("#zcLogo").html();
                var tdLogo = $("#tdLogo").html();
                var lsLogo = $("#lsLogo").html();
                var fcLogo = $("#fcLogo").html();
                var zqLogo = $("#zqLogo").html();
                var cqLogo = $("#cqLogo").html();
                var titleType = dataAll.titleType;

                if(sendType === 2){
                    //薪资
                    if(emailType != null){
                        if(emailType == '1'){
                            $("#foot").append($("#cardFootTempOne").html());
                        }else {
                            $("#foot").append($("#cardFootTempTwo").html());
                        }
                    }else {
                        //当月首次，确认邮件
                        $("#foot").append($("#cardFootTempOne").html());
                    }
                }else {
                    //考勤
                    $("#foot").append($("#cardFootTempOne").html());
                }

                switch (titleType) {
                    case 1:
                        $("#logo").append(zcLogo);
                        console.log("======:",1);
                        break;
                    case 2:
                        $("#logo").append(tdLogo);
                        console.log("======:",2);
                        break;
                    case 3:
                        $("#logo").append(lsLogo);
                        console.log("======:",3);
                        break;
                    case 4:
                        $("#logo").append(fcLogo);
                        console.log("======:",4);
                        break;
                    case 5:
                        $("#logo").append(htLogo);
                        console.log("======:",5);
                        break;
                    case 6:
                        $("#logo").append(zqLogo);
                        console.log("======:",6);
                        break;
                    case 7:
                        $("#logo").append(cqLogo);
                        break;
                    default:
                }

                if(contactName != null){
                    $("#contactName").html(contactName);
                }

                if (time != null) {
                    $("#sendTime").html(time);
                }
                if (checkTime != null) {
                    $("#checkTime").html(checkTime);
                }
                if(otherInfo != null){
                    $("#otherInfo").html(otherInfo);
                }

                if (salaryState != null && salaryState == 0) {
                    $ulTemp = $("<ul class=\"card__ul\"></ul>");
                    for (var i = 0; i < data.length; i++) {
                        if (data[i].isTop == 1) {
                            $("#topColmnName").html(data[i].dictName);
                            $("#topColmnValue").html(data[i].dictData);
                        }
                        $liTemp = $("<li class=\"card__li\"></li>");
                        $liTemp.append("<span class=\"card__li--left\" title='" + data[i].dictName + "'>" + data[i].dictName + "</span>");
                        if (data[i].dictData == null) {
                            $liTemp.append("<span class=\"card__li--right\"></span>");
                        } else {
                            $liTemp.append("<span class=\"card__li--right\">" + data[i].dictData + "</span>");
                        }
                        $ulTemp.append($liTemp);
                    }
                    $ulTemp.appendTo("#cardBody");
                    $('.js-card').show();
                }

            }
        }
    })
})
